import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import {render} from "@apps/antd-admin/src/hooks/render/renderUtils";
import {RenderType} from '@pkg/setting';
import {Api,companyList} from "./api";

export const columns: BasicColumn[] = [
  {
    title: '所属机构',
    dataIndex: 'companyName',
    width: 150,
  },
  {
    title: '报告编号',
    dataIndex: 'reportNo',
    width: 150,
  },
  {
    title: '姓名',
    dataIndex: 'userName',
    width: 120,
  },
  {
    title: '手机号',
    dataIndex: 'mobile',
    width: 120,
  },
  {
    title: '身份证号',
    dataIndex: 'cardNo',
    width: 150,
  },
  {
    title: '类别',
    dataIndex: 'reportType',
    dictData: [
      { label: '秒查', value: 1},
      { label: '惠查', value: 2 },
      { label: '精查', value: 3 },
    ],
    renderType: RenderType.DICT,
    width: 80,
  },
  {
    title: '授权方式',
    dataIndex: 'authorizeType',
    dictData: [
      { label: '当次有效', value: 1},
      { label: '6个月内', value: 2 },
      { label: '长期授权', value: 3 },
    ],
    renderType: RenderType.DICT,
    width: 80,
  },
  {
    title: '是否缓存',
    dataIndex: 'cached',
    dictData: [
      { label: '是', value: 1},
      { label: '否', value: 0 },
    ],
    renderType: RenderType.DICT,
    width: 80,
  },
  {
    title: '状态',
    dataIndex: 'state',
    width: 80,
    dictData: [
      { label: '已撤销', value: 0, color: '#a6a9a6' },
      { label: '正常', value: 1, color: '#09d550' }
    ],
    renderType: RenderType.DICT,
  },
  {
    title: '报告日期',
    dataIndex: 'reportDate',
    width: 120,
  },
  {
    title: '销毁日期',
    dataIndex: 'closeDate',
    width: 140,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '所属机构',
    field: 'companyId',
    component: 'ApiSelect',
    componentProps: {
      api: companyList,
      showSearch:true,
      immediate: true,
      labelField: 'companyName',
      valueField: 'companyId',
    },
  },
  {
    field: 'reportNo',
    label: '报告编号',
    component: 'Input',
    colProps: { span: 2 },
  },
  {
    field: 'userName',
    label: '姓名',
    component: 'Input',
    colProps: { span: 3 },
  },
  {
    field: 'mobile',
    label: '手机号',
    component: 'Input',
    colProps: { span: 3 },
  },
  {
    field: 'cardNo',
    label: '身份证号',
    component: 'Input',
    colProps: { span: 3 },
  },
  {
    field: 'reportType',
    label: '类别',
    component: 'Select',
    colProps: {span: 3},
    componentProps: {
      options: [
        {label: '秒查', value: 1},
        {label: '惠查', value: 2},
        {label: '精查', value: 3},
      ],
    }
  },
  {
    field: 'state',
    label: '报告状态',
    component: 'Select',
    colProps: {span: 3},
    componentProps: {
      options: [
        {label: '正常', value: 1},
        {label: '已销毁', value: 0},
      ],
    }
  }
];

export const formSchema: FormSchema[] = [
  {
    label: '报告编号',
    field: 'reportNo',
    component: 'Input',
  },
  {
    label: '姓名',
    field: 'userName',
    component: 'Input',
  },
  {
    field: 'reportType',
    label: '类别',
    component: 'ApiRadioGroup',
    componentProps: {
      options: [
        { label: '秒查', value: 1 },
        { label: '惠查', value: 2 },
        { label: '精查', value: 3 },
      ],
    },
  },
  {
    field: 'authorizeType',
    label: '授权方式',
    component: 'ApiRadioGroup',
    componentProps: {
      options: [
        { label: '当次有效', value: 1 },
        { label: '6个月内', value: 2 },
        { label: '长期授权', value: 3 },
      ],
    },
  },
  {
    field: 'cached',
    label: '是否缓存',
    component: 'ApiRadioGroup',
    componentProps: {
      options: [
        { label: '否', value: 0 },
        { label: '是', value: 1 },
      ],
    },
  },
  {
    field: 'reportConent',
    component: 'Input',
    label: '报告内容',
    slot: 'reportConent',
  },
];
